package com.example.config;

import org.springframework.context.annotation.Configuration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Configuration
public class WebCache extends HttpServlet {
    @Override
    public void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        String cache = request.getParameter("cache");
        if (cache != null)
        {
            if (cache.equals("false"))
            {
                // 关闭浏览器缓存
                response.setDateHeader("Expires", 0);
                response.setHeader("Cache-Control", "no-cache");
                response.setHeader("Pragma", "no-cache");
            }

        }
    }
}
